import json
import shutil
import os

# 读取JSON文件
with open('test_ocr_det.json', 'r') as f:
    data = json.load(f)

# 指定目标文件夹
target_dir = 'cwh_train_local/'

# 遍历images数组
for image in data['images']:
    # 获取文件名
    file_name = image['file_name']
    # 复制文件到指定目录
    shutil.copy('./' + file_name, target_dir + os.path.basename(file_name))